import {getStorage} from "@/utils/auth";
import application from "@/static/const/application";

export default {
    data() {
        return {
            //设置默认的分享参数
            share: {
                title: '律创法务小程序分享',
                path: '/pages/login',
                imageUrl: '',
                desc: '',
                content: ''
            },
        }
    },
    onShareAppMessage(res) {
        if (res.from === 'button') {// 来自页面内分享按钮
            console.log(res.target)
        }
        const userID = getStorage(application.user).userId;
        //获取用户类型
        const vipId = getStorage(application.user).vipId;
        console.log("用户类型", vipId);
        if (userID == null || userID == undefined || userID == "") {
            return {
                title: this.share.title,
                path: "/pages/login",
            }
        } else {
            if (vipId == "1" || vipId == "2") {
                return {
                    title: this.share.title,
                    path: "/pages/login?invitationId=" + userID,
                }
            } else {
                return {
                    title: this.share.title,
                    path: "/pages/login",
                }
            }
        }
    },
    //分享到朋友圈
    onShareTimeline(res) {
        const userID = getStorage(application.user).userId;
        //获取用户类型
        const vipId = getStorage(application.user).vipId;
        console.log("用户类型", vipId);
        if (userID == null || userID == undefined || userID == "") {
            return {
                title: this.share.title,
                path: "/pages/login",
            }
        } else {
            if (vipId == "1" || vipId == "2") {
                return {
                    title: this.share.title,
                    path: "/pages/login?invitationId=" + userID,
                }
            } else {
                return {
                    title: this.share.title,
                    path: "/pages/login",
                }
            }
        }
    },
    shareMessage(){

    }

}